import 'package:flutter/gestures.dart';
import 'package:flutter/material.dart';

class TextrichHomePage extends StatefulWidget {
  @override
  _TextrichHomePageState createState() => _TextrichHomePageState();
}

class _TextrichHomePageState extends State<TextrichHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
        appBar: AppBar(title: Text('text')),
        body: Center(
            child: SizedBox(
                width: 200,
                height: 100,
                child: Container(
                    alignment: Alignment(0, 0),
                    color: Colors.yellow,
                    child: Text.rich(TextSpan(
                        text: '这是textrich文本一',
                        style: TextStyle(color: Colors.lightBlue),
                        children: [
                          TextSpan(
                              text: '这是textrich文本二',
                              style: TextStyle(color: Colors.red)),
                          TextSpan(
                              text: '这是textrich文本三',
                              style: TextStyle(color: Colors.blue),
                              recognizer: TapGestureRecognizer()
                                ..onTap = () {
                                  print('点击了文本三');
                                }),
                          TextSpan(
                              text: '这是textrich文本四',
                              style: TextStyle(color: Colors.white)),
                        ]))))));
  }
}
